package leetcode.每日一题;

import org.junit.Test;

/**
 * @author ：zsy
 * @date ：Created 2022/11/19 11:36 PM
 * @description：
 */
public class 找到最高海拔 {
    @Test
    public void test() {
        System.out.println(new Solution().largestAltitude(new int[]{-5, 1, 5, 0, -7}));
    }

    class Solution {
        public int largestAltitude(int[] gain) {
            int ans = 0;
            int cur = 0;
            for (int g : gain) {
                cur += g;
                ans = Math.max(ans, cur);
            }
            return ans;
        }
    }
}
